function [Boxes] = BoxesCreate(Coords,BoxSize) 
% Create boxes for sugarcane proximity regions

CoordX = Coords(:,1);
CoordY = Coords(:,2);

minX = min(CoordX);
maxX = max(CoordX);

minY = min(CoordY);
maxY = max(CoordY);

LargerBox = max(BoxSize); i = 1;

for b = BoxSize
    GridX{i} = (minX-LargerBox/2):b:(maxX+LargerBox);
    GridY{i} = (minY-LargerBox/2):b:(maxY+LargerBox);
    
    sgX = length(GridX{i}); sgY = length(GridY{i});
    
    BoxIdxMap{i} = [ repmat((1:sgX)', [sgY 1]), kron((1:sgY)',ones(sgX,1)) ];
    
    [IdX] = ClassStates(CoordX, GridX{i}');
    [IdY] = ClassStates(CoordY, GridY{i}');
    
    BoxIdx{i} = 1 + (IdY - 1)*sgX + (IdX - 1);
    
    BSize{i} = b;

    i = i + 1;
end

Boxes.GridX     = GridX;
Boxes.GridY     = GridY;
Boxes.BoxIdxMap = BoxIdxMap;
Boxes.SingleIdx = BoxIdx; 
Boxes.BoxSize   = BSize;



